<style scoped>
.pro-con {
    padding: 0 20px;
    margin-bottom: 50px;
}

.pro-con .ivu-form-item {
    margin-bottom: 0;
}

.pro-con .ivu-col {
    padding-right: 0 !important;
}

.fr {
    float: right;
}

.pro-pagesize .mr10 {
    margin-right: 10px;
}

.search-h3 {
    font-size: 18px;
    color: #ef8412;
    font-weight: normal;
    margin-bottom: 20px;
}

/*//////////////////////////////*/

.search-h3 {
    font-size: 18px;
    color: #ef8412;
    font-weight: normal;
    margin-bottom: 20px;
}

.search-form {
    border-bottom: 1px solid #d9d9d9;
}

.search-form .ivu-col {
    margin-bottom: 15px;
}

.clear {
    clear: both;
}

.table-theme {
    clear: both;
}

.table-action {
    padding-top: 0;
    padding-bottom: 15px;
}

.pro-pagesize {
    margin-bottom: 10px;
}

.common-box-body.pr0 .ivu-form-item {
    padding-right: 0 !important;
}
</style>
<template>
    <div class="pro-list">
        <product-title></product-title>
        <div class="pro-con">
            <div class="pro-con-f common-box-body">
                <h3 class="search-h3 huang">
                    快速搜索
                </h3>
                <Form :model="searchForm">
                    <Row class="">
                        <Col :xs="24" :sm="24" :md="12" :lg="6">
                            <Form-item label="日期">
                                <DatePicker type="month" transfer placeholder="请选择日期" v-model="searchForm.old_dateTime" @on-change="datachange($event,searchForm,'dateTime')" :options="options3"></DatePicker>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="24" :md="12" :lg="6">
                            <Form-item label="机构">
                                <Select v-model="searchForm.yun_org_mid" transfer placeholder='请选择机构'>
                                    <Option value="0">全部</Option>
                                    <Option :value="item.id" v-for="item in allJG" :key="item.id">{{item.shortn}}</Option>
                                </Select>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="24" :md="12" :lg="6">
                            <Form-item label="员工工号">
                                <Input placeholder="请输入工号" v-model="searchForm.jobCode"></Input>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="24" :md="12" :lg="6">
                            <Form-item label="员工姓名">
                                <Input placeholder="请输入员工姓名" v-model="searchForm.name"></Input>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="24" :md="24" :lg="24" class="table-action">
                            <Button type="primary" size="large" class="fr mr10" @click="jisuan">计算</Button>
                        </Col>
                        <div class="clear"></div>
                    </Row>
                </Form>
            </div>
            <div class="table-theme highlight_table">
                <Table  ref="currentRowTable" size="large" stripe border :columns="header" :data="list"></Table>
            </div>
            <div id="footer">
                <Row class="pro-pagesize">
                    <Col :md="24" :lg="24" class="tRight">
                    <Page ref="pages" :total="classTotal" show-total show-sizer :current="p" show-elevator :page-size="pagesize" @on-change="pageChange" @on-page-size-change="pageSizeChange" placement="top" class="page"></Page>
                    </Col>
                </Row>
            </div>
        </div>
    </div>
</template>

<script>
import productTitle from "../../components/productTitle.vue";
import util from '../../libs/util'
import {getListByName} from '../../api/basiclaw'
export default {
    data() {
        return {
            options3:{
                    disabledDate (date) {
                        return date.valueOf() > Date.now() - 86400000;
                    }
                },
            rankList: [],
            total: 0,
            header: [
                {
                    type: "index",
                    title: "序号",
                    width: "60",
                    align: "center"
                },
                {
                    key: "jobCode",
                    title: "员工工号",
                    align: "center"
                },
                {
                    key: "employyeName",
                    title: "员工姓名",
                    align: "center"
                },
                {
                    key: "employyeLevel",
                    title: "当前职级",
                    align: "center"
                },
                {
                    key: "firstYearCommission",
                    title: "首期佣金",
                    align: "center"
                },
                {
                    key: "baseSalary",
                    title: "新人底薪",
                    align: "center"
                },
                {
                    key: "bole",
                    title: "伯乐奖",
                    align: "center"
                },
                {
                    key: "standardMembers",
                    title: "人力奖",
                    align: "center"
                },
                {
                    key: "platForm",
                    title: "平台奖",
                    align: "center"
                },
                {
                    key: "bred",
                    title: "育成奖",
                    align: "center"
                },
                {
                    key: "manage",
                    title: "管理奖",
                    align: "center"
                },
                {
                    key: "startUpBussiness",
                    title: "创业奖",
                    align: "center"
                },
                {
                    key:'total',
                    title: "合计",
                    align: "center",
                }
            ],
            p: 1,
            pagesize: 10,
            list: [],
            classTotal: 0,
            searchForm: {
                dateTime: "",
                old_dateTime: "",
                p: 1,
                pagesize: 10,
                name: "",
                jobCode:'',
                yun_org_mid:'',
                cid:'',
            },
            allJG:[]
        };
    },
    components: {
        productTitle
    },
    created() {
        this.getjg();
        let date = new Date().toLocaleDateString().split("/");
        date[1] = date[1] < 10 ? "0" + date[1] : date[1];
        this.searchForm.old_dateTime = date[0] + "-" + date[1];
        this.searchForm.dateTime = date[0] + "-" + date[1];
    },
    activated() {},
    methods: {
        pageChange(val) {
            this.p = val;
            this.jisuan();
        },
        pageSizeChange(val) {
            this.pagesize = val;
            this.jisuan();
        },
        search() {
            this.p = 1;
            this.get_data();
        },
        jisuan(){
            this.searchForm.p=this.p;
            this.searchForm.pagesize=this.pagesize;
            new Promise((rev,rej)=>{
                // let url="http://192.168.0.11:8180/kb/v1/rule/excuteAll/";
                let url=BASE_URL1+"/kb/v1/rule/excuteAll/";
                util.ajax.get(url,{
                    params:this.searchForm
                }).then(res=>{
                    if(res.data.err==0){
                        this.tableloading = false;
                        this.list=res.data.data.jsonList;
                        this.classTotal=res.data.data.count;
                        this.$Message.success('操作成功');
                    }else{
                        this.$Message.error(res.data.info);
                    }
                }).catch(error=>{
                    this.$Message.error('搜索失败');
                })
            })
        },
        //获取机构
        getjg(){
            new Promise((resolve, reject) => {
                    getListByName().then(response => {
                        if (response.data.err == 0) {
                            this.allJG = response.data.data;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
        },
         datachange(date, obj, attr) {
                obj[attr] = date;
            },
    }
};
</script>